package day8;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * @author oldliu
 * @since 1.0
 */
public class InputTest7 {
    public static void main(String[] args) {
        try {
            InputStream in=new FileInputStream("E:\\temp\\java78\\2.txt");
            byte[]b=new byte[100];//隐患，汉字会读半拉

            int length=0;
            while ((length= in.read(b))!=-1){
                System.out.println("读取了"+length);
                //转换成字符串String  byte数组->String
                String str=new String(b,0,length);
                System.out.println(str);
            }

//            for(int i=0;i<length;i++){
//                System.out.println(b[i]);
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
